﻿Public Class EntityConverterServiceImpl
    Implements IEntityConverterService

    Private expressionService As IExpressionService = New ExpressionServiceImpl

    Public Function ConverterHoleEntity(ByRef dr As DataRow) As HoleEntity Implements IEntityConverterService.ConverterHoleEntity
        Dim ent As New HoleEntity
        Try
            With ent
                .lineId = dr("line_id")
                .headId = dr("head_id")
                .schemeName = dr("scheme_name")
                .holeName = dr("hole_name")
                .sx = dr("sx")
                .sy = dr("sy")
                .sz = dr("sz")
                .face = dr("face")

                .inhibition = expressionService.eavl(dr, dr("inhibition"))
                .diameter = expressionService.eavl(dr, dr("diameter"))
                .depth = expressionService.eavl(dr, dr("depth"))
                .px = expressionService.eavl(dr, dr("px"))
                .py = expressionService.eavl(dr, dr("py"))
                .pz = expressionService.eavl(dr, dr("pz"))

                Return ent
            End With

        Catch ex As Exception
            MsgBox(ex.Message)
            Return Nothing

        End Try
    End Function


    Public Function ConverterPlateEntity(ByRef dr_parent As DataRow, ByRef dr_plate As DataRow) As PlateEntity Implements IEntityConverterService.ConverterPlateEntity
        Dim ent As New PlateEntity
        Try
            With ent
                .sx = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("sx"))
                .sy = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("sy"))
                .sz = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("sz"))
                .rx = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("rx"))
                .ry = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("ry"))
                .rz = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("rz"))
                .px = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("px"))
                .py = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("py"))
                .pz = expressionService.evalPlate(dr_parent, dr_plate, dr_plate("pz"))
            End With

            Return ent
        Catch ex As Exception
            MsgBox(ex.Message)
            Return Nothing
        End Try

    End Function
End Class
